﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace On_the_Fly
{
    public partial class Settings : Form
    {
        public Settings()
        {
            InitializeComponent();
        }

        FolderBrowserDialog fb = new FolderBrowserDialog();

        private void button1_Click(object sender, EventArgs e)
        {
            fb.Description = "Browse to, and select the path containing your TypeScript Compiler (tsc.exe).";
            if (fb.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {

                compilerPath.Text = fb.SelectedPath;
                groupBox1.Enabled = false;
            }


        }

        private void button2_Click(object sender, EventArgs e)
        {
            fb.Description = "Browse to, and select the path containing your TypeScript (.ts) files.";
            if (fb.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                workingDirectory.Text = fb.SelectedPath;
                groupBox2.Enabled = false;
            }
        }

        private void Settings_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (compilerPath.Text != null || compilerPath.Text.Length > 0)
            {
                Properties.Settings.Default.CompilerPath = compilerPath.Text;
            }

            if (workingDirectory.Text != null || workingDirectory.Text.Length > 0)
            {
                Properties.Settings.Default.WorkingDirectory = workingDirectory.Text;
            }

            Properties.Settings.Default.FirstTimeUser = false;
            Properties.Settings.Default.Save();

            this.Dispose(true);
        }
    }
}
